package com.sky.mapper;

import com.sky.context.BaseContext;
import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    //查询购物车
  @Select("select * from shopping_cart where user_id=#{userId}")
    public List<ShoppingCart> cartList(ShoppingCart shoppingCart);

  //查询当前用户购物车数据动态查询
   ShoppingCart cartByDishIdOrSetmealId(Long dishId, Long setmealId);

    //添加购物车
    void addCart(ShoppingCart shoppingCart);

    //根据套餐、菜品id查询价格
    @Select("select price from setmeal where id = #{setmealId}")
    BigDecimal getSetmealAmount(Long setmealId);
    @Select("select price from dish where id = #{dishId}")
    BigDecimal getDishAmount(Long dishId);

    //查询图片
    @Select("select image from setmeal where id = #{setmealId}")
    String getSetmealImage(Long setmealId);
    @Select("select image from dish where id = #{dishId}")
    String getDishImage(Long dishId);

    //查询名称
    @Select("select name from dish where id = #{dishId}")
    String getNameDish(Long dishId);
    @Select("select name from setmeal where id = #{setmealId}")
    String getNameSetmeal(Long setmealId);

    //删除购物车
    @Delete("delete from shopping_cart where dish_id = #{dishId} or setmeal_id = #{setmealId}")
    void delete(ShoppingCartDTO shoppingCartDTO);

    @Delete("delete from shopping_cart where user_id =#{userId}")
    void clean(Long userId);

    //修改数量
    void update(ShoppingCart shoppingCart);
}
